package com.gxa.modules.payment.service.impl;

import com.gxa.common.utils.Result;
import com.gxa.modules.payment.entity.PayItem;
import com.gxa.modules.payment.form.PayItemForm;
import com.gxa.modules.payment.mapper.PayItemMapper;
import com.gxa.modules.payment.service.PayItemService;
import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PayItemServiceImpl implements PayItemService {

    @Autowired
    private PayItemMapper payItemMapper;

    @Override
    public List<PayItem> queryByPage(Map<String, Object> params) {

        List<PayItem> payItems = this.payItemMapper.queryByPage(params);
        return payItems;
    }

//    @Override
//    public Result payItemAdd(PayItemForm payItemForm) {
//        Result r = new Result();
//        Integer code1 = payItemForm.getCode();
//        List<Integer> codes = this.payItemMapper.queryByMeterCode();
//        for(Integer code : codes){
//            if(code == code1){
//                r = new Result().error("仪表已添加");
//            }
//        }
//        this.payItemMapper.addPayItem(payItemForm);
//        return r;
//    }

    @Override
    public void payItemAdd(PayItemForm payItemForm) {
        this.payItemMapper.addPayItem(payItemForm);
    }

    @Override
    public List<PayItem> queryAll(Integer id) {
        List<PayItem> payItems = this.payItemMapper.queryAll(id);
        return payItems;
    }

    @Override
    public void payItemUpdate(PayItemForm payItemForm) {
        this.payItemMapper.updatePayItem(payItemForm);
    }

    @Override
    public void payItemDalete(Integer id) {
        this.payItemMapper.deletePayItem(id);
    }

    @Override
    public void payItemDaletes(List<Integer> ids) {
        this.payItemMapper.deletesPayItemIds(ids);
    }
}
